//
//  NSString+URLEncoding.m
//  CairnStory
//  www.cairnstory.com
//
//  Created by saturna on 10. 10. 23..
//  Copyright 2010 __MyCompanyName__. All rights reserved.
//

#import "NSString+URLEncoding.h"


@implementation NSString (URLEncoding)

- (NSString*)URLEncodedString
{
	//if (YES) return self;
    NSString *result = (NSString *)CFURLCreateStringByAddingPercentEscapes(kCFAllocatorDefault,
                                                                           (CFStringRef)self,
                                                                           NULL,
																		   CFSTR("!*'();:@&=+$,/?%#[]"),
                                                                           kCFStringEncodingUTF8);
    [result autorelease];
	return result;
}

- (NSString*)URLDecodedString
{
	//if (YES) return self;
	NSString *result = (NSString *)CFURLCreateStringByReplacingPercentEscapesUsingEncoding(kCFAllocatorDefault,
																						   (CFStringRef)self,
																						   CFSTR(""),
																						   kCFStringEncodingUTF8);
    [result autorelease];
	return result;
}

@end
